package cn.itcast.hotel.mq;

import cn.itcast.hotel.constants.MqConstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HotelListener {

    @Autowired
    private IHotelService hotelService;

    // 监听新增或修改
    @RabbitListener(queues = MqConstants.hotel_insert_queue)
    public void insertOrUpdate(Long id){
        hotelService.insertByid(id);
    }

    // 监听删除
    @RabbitListener(queues = MqConstants.hotel_delete_queue)
    public void delete(Long id){
        hotelService.deleteByid(id);
    }

}
